let vm = new Vue({
    el: '.main-container',  //选中整个main
    data() {
        return {
            area: {
                parentName:'',
                icon:''
            },//初始化对象     vue建议声明对象同时进行初始化，避免undefinded
        }
    },
    methods: {
        toSelect: function (id) {
            layer.open({
                type: 2,
                title: '选择',
                maxmin: true,
                // shadeClose: true, //点击遮罩关闭层
                area: ['90%', '70%'],
                content: 'area/select.html',
                end: () => {
                    if (layer.parentName != undefined&&layer.parentName.length > 0) {
                        this.area.parentName = layer.parentName;
                        this.area.parentId = layer.aid;
                        // console.log(this.area)
                    }
                }
            });
        },
        // modules/fontAwesome.html
        toModule: function (id) {
            layer.obj = id;
            layer.open({
                type: 2,
                title: '选择',
                maxmin: true,
                // shadeClose: true, //点击遮罩关闭层
                area: ['90%', '70%'],
                content: 'modules/fontAwesome.html',
                end: () => {
                    if (this.area.icon != layer.icon && layer.icon != this.area.icon && layer.icon.length > 0) {
                        this.area.icon = layer.icon;
                    }
                }
            });
        },
        add: function () {
            axios.post(
                "/guguanjia/manager/area/add", //相对路径同样受到base标签影响
                this.area
            ).then(
                response => {  //省略function关键字  自动传递上下文中的this
                    //this.apps = response.data.obj.list;
                    let index = parent.layer.getFrameIndex(window.name);//根据当前窗体名字获取其索引值
                    //console.log(index);
                    parent.layer.close(index);//根据索引值关闭子窗口
                    parent.layer.msg("更新成功");//根据索引值关闭子窗口
                }
            ).catch(error => {
                console.log(error.message);
            })
        },
        cancelAdd:function () {
            let index = parent.layer.getFrameIndex(window.name);//根据当前窗体名字获取其索引值
            //console.log(index);
            parent.layer.close(index);//根据索引值关闭子窗口
            parent.layer.msg("更新成功");//根据索引值关闭子窗口
        }
    },
});